package com.gjh.study.mybatis.mapper2;

import com.gjh.study.mybatis.domain.Person;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

/**
 * @author guangjh
 * @version 1.0
 * @date 2020/7/11 20:03
 */
public interface PersonMapper {
    @Select("select * from tb_person where id = #{id}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "sex", column = "sex"),
            @Result(property = "age", column = "age"),
            @Result(property = "card", column = "card_id",
                    one = @One(select = "com.gjh.study.mybatis.mapper2.CardMapper.selectCardById", fetchType = FetchType.EAGER)),
    })
    Person selectPersonById(Integer id);
}
